Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Jan 10, 2026

Simple fix implemented by Claude.

Since there is no corresponding issue, here are the details:

  • Add alt parameter to Typst image() calls for accessibility (PDF/UA compliance)
  • Follows same pattern as LaTeX writer: checks for explicit alt attribute first, falls back to image caption
  • If neither is available, omits alt

Background

Typst supports PDF/UA-1 accessibility standards via the alt parameter on image() calls. Without this, accessible PDFs generated through Typst fail validation with "missing alt text" errors.

Before:

#figure(image("cat.png"),
  caption: [
    A cat sleeping
  ]
)

After:

#figure(image("cat.png", alt: "A cat sleeping"),
  caption: [
    A cat sleeping
  ]
)

The implementation mirrors the existing LaTeX writer behavior where:

  1. Explicit {alt="..."} attribute takes priority
  2. Falls back to stringified image caption
  3. Omits alt parameter when no alt text is available

Pass alt text to Typst image() function for PDF/UA accessibility.
Follows same pattern as LaTeX writer: prefers explicit alt attribute,
falls back to stringified caption.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@gordonwoodhull
Copy link
Contributor Author

Oops, this is almost the same as #11394 - the only difference in output is that @mcanouil puts alt first after the filename, which I agree with. I'll close this and suggest a couple more tests there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant